<script type="text/javascript">

    function bulidP3() {
        $.ajax({
            type: "POST",
            url: "/ajax/fast_ajax.php?action=state",
            dataType: "text",
            contentType: "application/json;utf-8",
            data: "{}",
            timeout: 20000,
            error: function(a, b, c) { },
            success: function(data) {
                value = data.split("#"); $("#p3_cartNum").text(value[1].toString()); $("#p3_total").text(value[2].toString());
            }
        });

        $("#p3_img").attr("src", $("#productImg img").attr("src"));
        $("#p3_proName").text($("#productName").val());
        $("#p3_price").text($("#productPrice").val());
        $("#p3_sendPrice").text($("#productSendPrice").val());
        $("#p3_num").text($("#productNum").val());
    }

    function btnClsClick() {
        $("#p2").hide();
        InitP2();
        if ($("#p3 div").length >= 1) {
            $("#p3").hide();
        }
        $(".address_").attr("class", "addpanel_address");
        $("#itemUrl").removeAttr("disabled").val("");

        $("#promptInfo").attr("class", "addpanel_dhk").find("img").remove();
        $("#promptInfo p").text("请将您想代购商品的详细页网址粘贴到输入框中提交!");
        $("#addpanel_submit").removeAttr("disabled").attr("class", "addpanel_tijiao");
        $("#p1").show();
		$("#itemUrl").focus();
    }

    $(document).ready(function() {
        $("#productRemark").blur(function() { if ($.trim($(this).val()).length <= 0 || $(this).val() == "请选填颜色、尺寸等要求！") $(this).attr("class", "addpanel_still").val("请选填颜色、尺寸等要求！"); }).focus(function() { if ($(this).attr("class") == "addpanel_still") $(this).select().removeAttr("class"); }).click(function() { if ($(this).val() == "请选填颜色、尺寸等要求！") $(this).val(""); });

        $("#btnCls").click(btnClsClick);
		
	    $("#BuySelf").click(function() {
		 	$("#type1").toggle();
	    	$("#type2").toggle();
	    });
		
        var OnFail = function(XMLHttpRequest, textStatus, errorThrown) {
            alert("网络错误，请稍后再试");
        };
        var OnSuccess = function(resault) {
            $("#p2").hide();
            if (resault) {
                if ($("#p3 div").length >= 1) {
                    p3Init();
                    bulidP3();
                    $("#p3").show();
                }
                else {
                    $("#p3").load("/add/AddItemPanel/AddItemPanel3.htm", function() {
                        p3Init(); bulidP3(); $("#p3").show();
                    });
                }
            }
            else {
                alert("添加商品失败");
				btnClsClick();
            }
        }

        $("#successBtn").click(function() {
            if ($("#productPrice").attr("class") != "addpanel_hui") {
                addItem_productInfo.Price = $("#productPrice").val();
            }
			typevalue=$("#BuySelf").attr("checked");
			addItem_productInfo.chicun=$("#chicun").val();//获取尺寸信息
			addItem_productInfo.yanse=$("#yanse").val();//获取颜色信息
			addItem_productInfo.type=1;//默认是代购
			addItem_productInfo.expressno="";//默认快递号码是空
			if(typevalue==true){
			     if ($.trim($("#expressno").val()).length <= 0) {
					$("#expressno").focus();
					return;
           		 }else{
				 	addItem_productInfo.type=2;//获取是否是代发
				 	addItem_productInfo.expressno=$.trim($("#expressno").val());//获取颜色信
				 }
			}
            if ($.trim($("#productName").val()).length <= 0) {
                return;
            }
            if ($.trim($("#productPrice").val()).length <= 0) {
                return;
            }
            if ($.trim($("#productRemark").val()).length <= 0) {
                return;
            }

            var datasource = addItem_productInfo;

            $.ajax({
                type: "POST",
                url: "/ajax/fast_ajax.php?action=add",
                dataType: "json",
               // contentType: "application/json;utf-8",
                data:"adddata="+encodeURIComponent("{\"name\":'" + HtmlEncode($("#productName").val()) + "',\"href\":'" + $("#productUrl").val() + "',\"picture\":'" + datasource.Picture + "',\"thumbnail\":'" + datasource.Thumbnail + "',\"chicun\":'" + datasource.chicun + "',\"yanse\":'" + datasource.yanse + "',\"shopName\":'" + datasource.ShopName + "',\"shopHref\":'" + datasource.ShopHref + "',\"price\":" + datasource.Price + ",\"vipPrice1\":" + datasource.VIPPrice1 + ",\"vipPrice2\":" + datasource.VIPPrice2 + ",\"vipPrice3\":" + datasource.VIPPrice3 + ",\"buyNum\":" + $("#productNum").val() + ",\"freight\":" + $("#productSendPrice").val() + ",\"isAuction\":" + datasource.IsAuction + ",\"remark\":'" + $("#productRemark").val()  + "',\"type\":" + datasource.type  + ",\"expressno\":'" + datasource.expressno + "'}"),
                timeout: 10000,
                error: OnFail,
                success: OnSuccess
            });
        });
    });
</script>

<div class="addpanel_procedure">
    <img src="/add/newimages/procedure.gif" alt="一键填单" />
</div>
<div class="addpanel_wangzhi">
    <dl>
        <dt>购买商品页网址：</dt>
        <dd>
            <input id="productUrl" class="addpanel_hui" name="" type="text" value="" disabled="disabled" /></dd>
    </dl>
    <p id="proAlert">
        恭喜您！商品信息抓取成功，您可以修改购买数量和填写商品备注！</p>
</div>
<div class="addpanel_data">
    <div id="productImg" class="addpanel_img">
        <img src="" onerror="this.src='/add/newimages/noimg80.gif'" alt="" />
    </div>

    <table>
        <tr>
            <td class="addpanel_zuo">
                商品名称：
            </td>
            <td>
                <input class="addpanel_k" id="productName" type="text" value="" />
            </td>
        </tr>
        <tr>
            <td class="addpanel_zuo">
                商品价格：
            </td>
            <td>
                <input class="" maxlength="7" id="productPrice" type="text" onkeyup="value=value.replace(/[^\d\.]/g,'')" /><span>RMB</span>
            </td>
		
        </tr>
        <tr>
            <td class="addpanel_zuo">
                国内运费：
            </td>
            <td>
                <div id="question" class="addpanel_fare">
                    <div>
                        <h2>
                            关于商品运费的问题</h2>
                        <a href="javascript:;" onclick='$("#question").hide();' title="关闭"></a>
                    </div>
                    <p>
                        因为系统未能抓取到商品的运费，统一默认为RMB&nbsp;10元，如果与实际金额有出入，请在提交代购单后，与客服人员联系，修改运费！
                    </p>
                    <p>
                    给您带来不便，请见谅；祝您在本站代购愉快！
                </div>
                <input class="" id="productSendPrice" type="text" /><span>RMB</span>
            </td>
        </tr>
        <tr>
            <td class="addpanel_zuo">
                购买数量：
            </td>
            <td>
                <input type="text" onkeyup="value=value.replace(/[^\d]/g,'')" maxlength="6" value="1" onblur="if(this.value.length&lt;=0) this.value=1;" id="productNum"><a onclick="$('#productNum').val(parseInt($('#productNum').val())+1);" title="增加数量" href="javascript:void('0')" id="numAdd"></a><a onclick="var tb=$('#productNum'); parseInt(tb.val())&lt;2?1:tb.val(parseInt(tb.val())-1);" title="减少数量" href="javascript:void('0')" class="addpanel_jian" id="numMis"></a>
            </td>
        </tr>
        <tr>
            <td class="addpanel_zuo">
                商品尺寸：<input id="productThumbnail" type="hidden" style="display:none;"/>
            </td>
            <td> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                   
                    <td width="105" align="left"> <input type="input" id="chicun" style="width:80px;" value=""  /></td>
                   
                    <td width="70" align="left">商品颜色：</td>
                    <td align="left"><input type="input" id="yanse"  style="width:80px;" value="" /></td>
              </tr>
          </table>
               
          </td>
		
        </tr>
        <tr>
            <td class="addpanel_zuo">
                商品备注：
            </td>
            <td>
                <textarea class="addpanel_still" id="productRemark" cols="" rows="">请选填颜色、尺寸等要求！</textarea>
            </td>
        </tr>
    </table>
</div>
<div class="addpanel_go">
    <input disabled="disabled" class="addpanel_next_no" id="successBtn" name="" type="button"
        onmouseover="this.className='addpanel_next_'" onmouseout="this.className='addpanel_next'" />
    <a href="javascript:void('0')" id="btnCls">[清空]</a>&nbsp;
	<div style="float:left;padding:0px; margin:0px; line-height:28px">代发：<input name="BuySelf" id="BuySelf" type="checkbox" value="2" />
	<span id="type1" style="COLOR: #f90">选中代发表示商品由你自己购买</span>
	<span id="type2" style="display:none;">&nbsp;快递单号：<input name="expressno" type="input" id="expressno" style="width:80px;" value="">&nbsp;<font color="#ff9900">必填</font>
	</span>
	</div>
</div>
